﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net;

namespace TFSAutoNotify.WindowsService
{
    class Email
    {
        public static void sendEmail()
        {
            MailMessage mail = new MailMessage();
            MailAddressCollection mailAdress = new MailAddressCollection();
            mailAdress.Add("william_wang@live.com");

        }
        //public static void CreateTestMessage4(string server)
        //{
        //    MailAddress from = new MailAddress("ben@contoso.com");
        //    MailAddress to = new MailAddress("Jane@contoso.com");
        //    MailMessage message = new MailMessage(from, to);
        //    message.Subject = "Using the SmtpClient class.";
        //    message.Body = @"Using this feature, you can send an e-mail message from an application very easily.";
        //    SmtpClient client = new SmtpClient(server);
        //    Console.WriteLine("Sending an e-mail message to {0} by using SMTP host {1} port {2}.",
        //         to.ToString(), client.Host, client.Port);

        //    try
        //    {
        //        client.Send(message);
        //    }
        //    catch (Exception ex)
        //    {
        //        Console.WriteLine("Exception caught in CreateTestMessage4(): {0}",
        //              ex.ToString());
        //    }
        //}
        public static void CreateTestMessage1()
        {
            string to = "i-jibw@wicresoft.com";
            string from = "TFSAutoNotify@alcatel-sbell.com.cn";
            string subject = "Using the new SMTP client.";
            string body = @"Using this new feature, you can send an e-mail message from an application very easily.";
            MailMessage message = new MailMessage(from, to, subject, body);
            SmtpClient client = new SmtpClient("172.24.146.133",25);
            // Credentials are necessary if the server requires the client 
            // to authenticate before it will send e-mail on the client's behalf.
            //client.Credentials = CredentialCache.DefaultNetworkCredentials;

            try
            {
                client.Send(message);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception caught in CreateTestMessage1(): {0}",
                      ex.ToString());
            }
        }


    }
}
